package com.MediaVaultTest;
import com.MediaVaultTest.Media;
import java.util.LinkedList;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import com.google.appengine.api.datastore.Key;

@PersistenceCapable
public class UserStore {
	
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;
	
	@Persistent
	private String email;
	
	@Persistent(mappedBy = "userStore")
	private LinkedList<Media> listOfMedia;
	
	@Persistent
	private long mbUpload;
	
	@Persistent
	private long mbDownload;
	
	@Persistent
	private long mbStorage;
	
	public UserStore(String email, int Up, int Down, int Store) {
		this.email = email;
		this.mbUpload = Up;
		this.mbDownload = Down;
		this.mbStorage = Store;
		this.listOfMedia = new LinkedList<Media>();
	}
	
	public Key getKey(){
		return  key;	
	}
	
	public void setKey(Key key){
		this.key = key;
	}
	
	public String getEmail(){
		return email;
	}
	
	public long getmbUpload(){
		return mbUpload;
	}
	
	public long getmbDownload(){
		return mbDownload;
	}
	
	public long getmbStorage(){
		return mbStorage;
	}
	
	public void setmbStorage(long quota){
		mbStorage = quota;
	}
	
	public void setmbUpload(long up){
		mbUpload = up;
	}
	
	public void setmbDownload(long down){
		mbDownload = down;
	}
	
	public void addMediaFile(Media NewMedia){
		listOfMedia.add(NewMedia);
	}
	
	public void removeMediaFile(Media OldMedia){
		listOfMedia.remove(OldMedia);
	}
	
	public LinkedList<Media> getMedia(){
		return listOfMedia;
	}
	
	public Media getIndMedia(int index){
		return listOfMedia.get(index);
	}
	
	public int getSizeOfMedia(){
		if (listOfMedia==null){
			return 0;
		} else {
			return listOfMedia.size();
		}
	}
}
